﻿Imports System.Data
Imports FirebirdSql.Data
Imports FirebirdSql.Data.FirebirdClient

Public Class _cargoFuncao
    Inherits _DataBase
    Private _idCargofuncao As Integer
    Public Property idCargofuncao() As Integer
        Get
            Return _idCargofuncao
        End Get
        Set(ByVal value As Integer)
            _idCargofuncao = value
        End Set
    End Property
    Private _dsCargoFuncao As String
    Public Property dsCargoFuncao() As String
        Get
            Return _dsCargoFuncao
        End Get
        Set(ByVal value As String)
            _dsCargoFuncao = value
        End Set
    End Property

    Public Function consultaCargoFuncao() As DataSet
        conectaDb()
        consultaCargoFuncao = retornaDataSet(montaParametro("SP_CARGOFUNCAO_CONSULTA", "TODOS"))
        desconectaDb()
    End Function
    Public Function consultaCargoFuncaoPorId() As Boolean
        conectaDb()
        dr = retornaDataReader(montaParametro("SP_CARGOFUNCAO_CONSULTA", "ID"))
        With dr
            If .Read Then
                dsCargoFuncao = .Item("O_DS_CARGOFUNCAO")
            End If
        End With
    End Function

    Public Sub insereCargoFuncao()
        conectaDb()
        execSQLSemRetorno(montaParametro("SP_CARGOFUNCAO_CMD", "INSERIR"))
        desconectaDb()
    End Sub
    Public Sub alteraCargoFuncao()
        conectaDb()
        execSQLSemRetorno(montaParametro("SP_CARGOFUNCAO_CMD", "ALTERAR"))
        desconectaDb()
    End Sub

    Private Function montaParametro(ByVal nomeSP As String, ByVal pModo As String) As FbCommand
        With cmd
            .CommandText = nomeSP
            With .Parameters
                .Clear()
                .Add("MODO", FbDbType.VarChar, 10).Value = pModo
                .Add("I_ID_CARGOFUNCAO", FbDbType.Integer).Value = idCargofuncao
                .Add("I_DS_CARGOFUNCAO", FbDbType.VarChar, 80).Value = dsCargoFuncao
            End With
        End With
        Return cmd
    End Function


End Class
